package com.kantboot.system.admin.web.admin.controller;

import com.kantboot.system.admin.domain.dto.BindPermissionDTO;
import com.kantboot.system.admin.domain.dto.SysAdminRouterSearchDTO;
import com.kantboot.system.admin.domain.entity.SysAdminRouter;
import com.kantboot.system.admin.service.ISysAdminRouterService;
import com.kantboot.util.common.result.RestResult;
import com.kantboot.util.core.controller.BaseAdminController;
import com.kantboot.util.core.param.PageParam;
import com.kantboot.util.core.result.PageResult;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/system-admin-web/admin/router")
public class SysAdminRouterControllerOfAdmin
extends BaseAdminController<SysAdminRouter,Long>
{

    @Resource
    private ISysAdminRouterService service;

    @RequestMapping("/getBodyData")
    public RestResult<PageResult> getBodyData(@RequestBody PageParam<SysAdminRouterSearchDTO> pageParam) {
        return RestResult.success(service.getBodyData(pageParam),"getSuccess","获取成功");
    }

    @RequestMapping("/getList")
    public RestResult<List<SysAdminRouter>> getList() {
        return RestResult.success(service.getList(),"getSuccess","获取成功");
    }

    @RequestMapping("/getListByUserId")
    public RestResult<List<SysAdminRouter>> getListByUserId(@RequestParam("userId") Long userId) {
        return RestResult.success(service.getListByUserId(userId),"getSuccess","获取成功");
    }

    @RequestMapping("/getSelfList")
    public RestResult<List<SysAdminRouter>> getSelfList() {
        return RestResult.success(service.getSelfList(),"getSuccess","获取成功");
    }

    @RequestMapping("/getSelfTopList")
    public RestResult<List<SysAdminRouter>> getSelfTopList() {
        return RestResult.success(service.getSelfTopList(),"getSuccess","获取成功");
    }

    @RequestMapping("/bindPermission")
    public RestResult<Void> bindPermission(@RequestBody BindPermissionDTO dto) {
        service.bindPermission(dto);
        return RestResult.success(null,"bindSuccess","绑定成功");
    }

    @RequestMapping("/getPermissionCodeListByRouterCode")
    public RestResult<List<String>> getPermissionCodeListByRouterCode(@RequestParam("routerCode") String routerCode) {
        return RestResult.success(service.getPermissionCodeListByRouterCode(routerCode),"getSuccess","获取成功");
    }

}
